<!DOCTYPE html>
<html lang="en">
  <head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta name="author" content="Zhou Wei <zromyk@163.com>">
  <title>firewalld</title>
  <link rel="shortcut icon" href="/favicon.ico">
  <link rel="stylesheet" href="/style/pure.css">
  <link rel="stylesheet" href="/style/main.css">
  <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/4.7.0/css/font-awesome.css">
  <link href="https://apps.bdimg.com/libs/highlight.js/9.1.0/styles/default.min.css" rel="stylesheet">
  <script src='/style/baidu.js'></script>
</head>
<body>
  <div id="menu-background"></div>
  <div id="menu">
    <div class="pure-menu pure-menu-horizontal">
  <div id="menu-block">
    <ul class="pure-menu-list">
      <a class="pure-menu-heading" href="/index.html">ZROMYK</a>
<li class="pure-menu-item">
  <a class="pure-menu-link" href="/index.html">主页</a>
</li>
<li class="pure-menu-item">
  <a class="pure-menu-link" href="/public/archive/index.html">归档</a>
</li>
<li class="pure-menu-item">
  <a class="pure-menu-link" href="/public/download/index.html">下载</a>
</li>
<li class="pure-menu-item">
  <a class="pure-menu-link" href="/public/feedback/index.html">反馈</a>
</li>
<li class="pure-menu-item">
  <a class="pure-menu-link" href="/public/about/index.html">关于我</a>
</li>
<li class="pure-menu-item">
  <a class="pure-menu-link" href="https://github.com/zromyk"><i class="fa fa-github" style="font-size:32px"></i></a>
</li>

    </ul>
  </div>
</div>

  </div>
  <div id="layout">
    <div class="content">
      <div id="content-articles">
  <h1 id="firewalld" class="content-subhead">firewalld</h1>
  <p>
    <span>2020-10-11</span>
    <span><span class="post-category post-category-other">Network</span></span>
    <span id="/public/article/firewalld.html" class="leancloud_visitors" style="display:none" data-flag-title="firewalld"></span>
  </p>
  <h3 id="1-firewalld">1. firewalld的基本使用</h3>
<ol>
<li>启动： systemctl start firewalld</li>
<li>关闭： systemctl stop firewalld</li>
<li>查看状态： systemctl status firewalld </li>
<li>开机禁用  ： systemctl disable firewalld</li>
<li>开机启用  ： systemctl enable firewalld</li>
</ol>
<h3 id="2-systemctlcentos7servicechkconfig">2. systemctl是CentOS7的服务管理工具中主要的工具，它融合之前service和chkconfig的功能于一体。</h3>
<ol>
<li>启动一个服务：systemctl start firewalld.service</li>
<li>关闭一个服务：systemctl stop firewalld.service</li>
<li>重启一个服务：systemctl restart firewalld.service</li>
<li>显示一个服务的状态：systemctl status firewalld.service</li>
<li>在开机时启用一个服务：systemctl enable firewalld.service</li>
<li>在开机时禁用一个服务：systemctl disable firewalld.service</li>
<li>查看服务是否开机启动：systemctl is-enabled firewalld.service</li>
<li>查看已启动的服务列表：systemctl list-unit-files|grep enabled</li>
<li>查看启动失败的服务列表：systemctl &ndash;failed</li>
</ol>
<h3 id="3-firewalld-cmd">3. 配置firewalld-cmd</h3>
<ol>
<li>查看版本： firewall-cmd &ndash;version</li>
<li>查看帮助： firewall-cmd &ndash;help</li>
<li>显示状态： firewall-cmd &ndash;state</li>
<li>查看所有打开的端口： firewall-cmd &ndash;zone=public &ndash;list-ports</li>
<li>更新防火墙规则： firewall-cmd &ndash;reload</li>
<li>查看区域信息:  firewall-cmd &ndash;get-active-zones</li>
<li>查看指定接口所属区域： firewall-cmd &ndash;get-zone-of-interface=eth0</li>
<li>拒绝所有包：firewall-cmd &ndash;panic-on</li>
<li>取消拒绝状态： firewall-cmd &ndash;panic-off</li>
<li>查看是否拒绝： firewall-cmd &ndash;query-panic</li>
</ol>
<p>添加</p>
<pre><code class="pre-wrap"><span style="overflow-x: auto; max-width:100%; display:inline;"><code>firewall-cmd --zone=public --add-port=80/tcp --permanent
（--permanent永久生效，没有此参数重启后失效）
</code></span></code></pre>
<p>重新载入</p>
<pre><code class="pre-wrap"><span style="overflow-x: auto; max-width:100%; display:inline;"><code>firewall-cmd --reload
</code></span></code></pre>
<p>查看</p>
<pre><code class="pre-wrap"><span style="overflow-x: auto; max-width:100%; display:inline;"><code>firewall-cmd --zone= public --query-port=80/tcp
</code></span></code></pre>
<p>删除</p>
<pre><code class="pre-wrap"><span style="overflow-x: auto; max-width:100%; display:inline;"><code>firewall-cmd --zone= public --remove-port=80/tcp --permanent
</code></span></code></pre>
</div>
<div id="nav">
  <div class="navigation">
  <ul class="pure-menu-list">
    <li class="pure-menu-item">
  <a class="pure-menu-link" style="padding:0.1em 0em 0.1em 1.25em;" href="#1-firewalld">1. firewalld的基本使用</a>
</li>
<li class="pure-menu-item">
  <a class="pure-menu-link" style="padding:0.1em 0em 0.1em 1.25em;" href="#2-systemctlcentos7servicechkconfig">2. systemctl是CentOS7的服务管理工具中主要的工具，它融合之前service和chkconfig的功能于一体。</a>
</li>
<li class="pure-menu-item">
  <a class="pure-menu-link" style="padding:0.1em 0em 0.1em 1.25em;" href="#3-firewalld-cmd">3. 配置firewalld-cmd</a>
</li>

  </ul>
</div>

</div>
 
    </div>
  </div>
  <div id="footer-background">
    <div id="footer">
      <div class="legal pure-g">
  <div class="pure-u-1 u-sm-1-2">
    <p class="legal-license"><a href="https://beian.miit.gov.cn/#/Integrated/index">浙ICP备2020038748号</a></p>
  </div>
  <div class="pure-u-1 u-sm-1-2">
    <p class="legal-links"><a href="https://github.com/zromyk">GitHub</a></p>
    <p class="legal-copyright">Copyright © 2021 Wei Zhou. 保留所有权利。</p>
  </div>
</div>
    </div>
  </div>
  <script src='/style/latest.js?config=TeX-MML-AM_CHTML'></script>
  <script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
  <script src='/style/Valine.min.js'></script>
  <script src="https://apps.bdimg.com/libs/highlight.js/9.1.0/highlight.min.js"></script>
  <script type="text/javascript">
    hljs.initHighlightingOnLoad();
  </script>
  <script src="https://cdn.geogebra.org/apps/deployggb.js"></script>
  <script src="https://cdn1.lncld.net/static/js/2.5.0/av-min.js"></script>
  <script src='/style/readTimes.js'></script>
</body>
</html>
